var express = require("express");
var router = express.Router();

  router.get("/hot-list", function (req, res, next) {
    // req为客户端发送的请求参数数据
    // res为服务端返回的数据
    const body = [
      {
        id: 1,
        imgUrl: "http://www.dell-lee.com/imgs/vue3/near.png",
        name: "沃尔玛",
        sales: 10000,
        expressLimit: 0,
        expressPrice: 0,
        slogan: "VIP尊享满89元减4元运费券（每月3张）"
      },
      {
        id: 2,
        imgUrl: "http://www.dell-lee.com/imgs/vue3/near.png",
        name: "沃尔玛",
        sales: 2000,
        expressLimit: 0,
        expressPrice: 5,
        slogan: "VIP尊享满89元减4元运费券（每月3张）"
      }
    ];
    // 调用res.send将数据响应给客户端
    res.send({
        errno: 0,
        msg: "请求成功",
        data: body,
    });
  });
  
  router.get("/shop/id", function (req, res, next) {
    // req为客户端发送的请求参数数据
    // res为服务端返回的数据
    const body =  {
      id: 1,
      imgUrl: "http://www.dell-lee.com/imgs/vue3/near.png",
      name: "沃尔玛",
      sales: 10000,
      expressLimit: 0,
      expressPrice: 0,
      slogan: "VIP尊享满89元减4元运费券（每月3张）"
    };
    // 调用res.send将数据响应给客户端
    res.send({
        errno: 0,
        msg: "请求成功",
        data: body,
    });
  });

  router.get("/shop/id/products", function (req, res, next) {
    // req为客户端发送的请求参数数据
    // res为服务端返回的数据
    const body =  [{
      _id: 1,
      name: "番茄250g/份",
      imgUrl:'http://www.dell-lee.com/imgs/vue3/tomato.png',
      sales: 10,
      price:33.6,
      oldPrice:100
    },{
      _id: 2,
      name: "草莓250g/份",
      imgUrl:'http://www.dell-lee.com/imgs/vue3/tomato.png',
      sales: 10,
      price:33.6,
      oldPrice:110
    },{
      _id: 3,
      name: "提子250g/份",
      imgUrl:'http://www.dell-lee.com/imgs/vue3/tomato.png',
      sales: 10,
      price:33.6,
      oldPrice:110
    },{
      _id: 4,
      name: "提子250g/份",
      imgUrl:'http://www.dell-lee.com/imgs/vue3/tomato.png',
      sales: 10,
      price:33.6,
      oldPrice:110
    },];
    // 调用res.send将数据响应给客户端
    res.send({
        errno: 0,
        msg: "请求成功",
        data: body,
    });
  });

  // 创建订单
  router.post("/order", function (req, res, next) {
    const body =  [
      {
        "address": {
          "city": "北京",
          "department": "xx小区",
          "houseNumber": "门牌号",
          "name": "张三",
          "phone": "18611112222"
        },
        "shopId": "1",
        "shopName": "沃尔玛",
        "isCanceled": false,
        "products": [
          {
            "orderSales": 5,
            "product": {
              "name": "番茄 250g / 份",
              "img": "http://www.dell-lee.com/imgs/vue3/tomato.png",
              "price": 33.6,
              "sales": 6
            }
          },
          {
            "orderSales": 10,
            "product": {
              "name": "车厘子 500g / 份",
              "img": "http://www.dell-lee.com/imgs/vue3/cherry.png",
              "price": 33.6,
              "sales": 6
            }
          }
        ]
      }
    ]

    res.send({
        errno: 0,
        msg: "请求成功",
        data: body,
    });
  });

  // 订单列表
  router.get("/orderList", function (req, res, next) {
    const body =  [
      {
        "address": {
          "city": "北京",
          "department": "xx小区",
          "houseNumber": "门牌号",
          "name": "张三",
          "phone": "18611112222"
        },
        "shopId": "1",
        "shopName": "沃尔玛",
        "isCanceled": false,
        "products": [
          {
            "orderSales": 5,
            "product": {
              "name": "番茄 250g / 份",
              "img": "http://www.dell-lee.com/imgs/vue3/tomato.png",
              "price": 33.6,
              "sales": 6
            }
          },
          {
            "orderSales": 10,
            "product": {
              "name": "车厘子 500g / 份",
              "img": "http://www.dell-lee.com/imgs/vue3/cherry.png",
              "price": 33.6,
              "sales": 6
            }
          }
        ]
      }
    ]

    res.send({
        errno: 0,
        msg: "请求成功",
        data: body,
    });
  });

  // 订单列表
  router.get("/search", function (req, res, next) {
    const body =  [
      {
        "_id": "1",
        "name": "沃尔玛",
        "imgUrl": "http://www.dell-lee.com/imgs/vue3/near.png",
        "sales": 10000,
        "expressLimit": 0,
        "expressPrice": 5,
        "slogan": "VIP尊享满89元减4元运费券",
        "products": [
          {
            "name": "番茄250g/份",
            "imgUrl": "http://www.dell-lee.com/imgs/vue3/tomato.png",
            "price": 33.6,
            "oldPrice": 39.6
          },
          {
            "name": "车厘子 500g / 份",
            "imgUrl": "http://www.dell-lee.com/imgs/vue3/cherry.png",
            "price": 99,
            "oldPrice": 119.6
          },
          {
            "name": "橙子 500g/份",
            "imgUrl": "http://www.dell-lee.com/imgs/vue3/orange.png",
            "price": 12.6,
            "oldPrice": 22.6
          }
        ]
      }
    ]

    res.send({
        errno: 0,
        msg: "请求成功",
        data: body,
    });
  });

  module.exports = router;